package com.zengdb.mybatis.service.impl;

import java.util.Arrays;
import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.zengdb.mybatis.dao.StudentMapper;
import com.zengdb.mybatis.domain.Student;
import com.zengdb.mybatis.service.IStudentService;
import com.zengdb.mybatis.util.MyBatisUtil;

public class StudentServiceImpl implements IStudentService{

	@Override
	public void saveOne(Student student) {
		saveMulti(Arrays.asList(student));
		/*SqlSession session = MyBatisUtil.openSession();
		StudentMapper dao = session.getMapper(StudentMapper.class);
		dao.saveOne(student);
		session.commit();
		session.close();*/
	}

	@Override
	public void saveMulti(List<Student> students) {
		SqlSession session = MyBatisUtil.openSession();
		StudentMapper dao = session.getMapper(StudentMapper.class);
		dao.saveMulti(students);
		session.commit();
		session.close();
	}

}
